package com.ethanJun.csdn.domain.service;

import cn.hutool.json.JSONUtil;
import com.ethanJun.csdn.domain.model.ArticleToolRequest;
import com.ethanJun.csdn.domain.model.ArticleToolResponse;
import com.ethanJun.csdn.infrastructure.ICSDNService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * @author 衣立君
 * @date 2025/04/22 21:10
 **/
@Slf4j
@Service
public class CsdnArticleToolComponent {

    @Resource
    private ICSDNService csdnService;


    @Tool(description = "发布文章到CSDN")
    public ArticleToolResponse pushArticleToCsdn(ArticleToolRequest articleToolRequest) throws IOException {
        log.info("CSDN发帖接口数据：{}", JSONUtil.toJsonStr(articleToolRequest));
        return csdnService.writerArticle(articleToolRequest);
    }

}